Imports System.Data.SqlClient

Imports System.IO
Public Class Educations

    Public Shared Sub AddEducation(ByVal edu As EducationInfo)


        CmdPro.Begin()

        Try


            CmdPro.Parameters("@employeeId") = edu.EmployeeId
            CmdPro.Parameters("@duration") = edu.Duration
            CmdPro.Parameters("@major") = edu.Major
            CmdPro.Parameters("@certificate") = edu.Certificate
            CmdPro.Parameters("@schoolName") = edu.SchoolName
            CmdPro.Parameters("@country") = edu.Country
            CmdPro.Parameters("@note") = edu.Note
            CmdPro.Parameters("@educationGroup") = edu.EducationGroup
            CmdPro.Parameters("@GPA") = edu.Gpa
            CmdPro.Parameters("@graduateYear") = edu.GraduateYear
            CmdPro.Parameters("@active") = edu.Active
            edu.EducationId = CmdPro.ExecuteNonQuery("InsertEducation", "@id")
            CmdPro.Commit()


        Catch ex As Exception


            CmdPro.Rollback()


            MsgBox(ex.Message)


        End Try


    End Sub

    Public Shared Sub UpdateEducation(ByVal edu As EducationInfo)


        CmdPro.Begin()

        Try

            CmdPro.Parameters("@id") = edu.EducationId
            CmdPro.Parameters("@employeeId") = edu.EmployeeId
            CmdPro.Parameters("@duration") = edu.Duration
            CmdPro.Parameters("@major") = edu.Major
            CmdPro.Parameters("@certificate") = edu.Certificate
            CmdPro.Parameters("@schoolName") = edu.SchoolName
            CmdPro.Parameters("@country") = edu.Country
            CmdPro.Parameters("@note") = edu.Note
            CmdPro.Parameters("@educationGroup") = edu.EducationGroup
            CmdPro.Parameters("@GPA") = edu.Gpa
            CmdPro.Parameters("@graduateYear") = edu.GraduateYear
            CmdPro.Parameters("@active") = edu.Active
            edu.EducationId = CmdPro.ExecuteNonQuery("UpdateEducation")
            CmdPro.Commit()


        Catch ex As Exception


            CmdPro.Rollback()


            MsgBox(ex.Message)


        End Try


    End Sub

    Public Shared Sub DeleteEducation(ByVal edu As EducationInfo)

        CmdPro.Begin()
        Try
            CmdPro.Parameters("@id") = edu.EducationId
            CmdPro.ExecuteNonQuery("DeleteEducation")
            CmdPro.Commit()
        Catch ex As Exception
            CmdPro.Rollback()
            MsgBox(ex.Message)
        End Try
    End Sub
 
    Public Shared Function GetEducation() As DataTable
        Try
            Str = "SELECT EDUCATOIN_ID,EMPLOYEE_NAME=ENGLISH_NAME +' ( '+KHMER_NAME+' )',DURATION,MAJOR,CERTIFICATE,SCHOOL_NAME,COUNTRY,NOTE,EDUCATION_GROUP,GPA,GRADUATE_YEAR FROM VIEW_EDUCATION  WHERE ACTIVE=1 ORDER BY EDUCATOIN_ID ASC"
            Dim dataAdapter As SqlDataAdapter
            dataAdapter = New SqlDataAdapter(Str, CType(Dbinterface.Connection, SqlConnection))
            Dim dataTable As DataTable = New DataTable()
            dataAdapter.Fill(dataTable)
            Return dataTable
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
            Return Nothing
        End Try
    End Function

    

End Class